package com.light.mytext.webview

import android.graphics.Bitmap
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.webkit.WebView
import android.webkit.WebViewClient
import com.light.mytext.R
import kotlinx.android.synthetic.main.activity_webview.*

class WebviewActivity : AppCompatActivity() {
    private var time: TimeCount? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_webview)
        init()
    }
    fun init() {
        time = TimeCount(60000, 1000)
        web_live.settings.javaScriptEnabled = true//设置能够解析Javascript
        web_live.settings.domStorageEnabled = true//设置适应Html5


//        web_live.loadUrl(intent.getStringExtra("url"))
        web_live.loadUrl("https://blog.csdn.net/wz_1992/article/details/115934990")
        web_live.webViewClient = object : WebViewClient() {
            override fun onPageFinished(view: WebView?, url: String?) {
                super.onPageFinished(view, url)
            }

            override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
                super.onPageStarted(view, url, favicon)
            }
        }

    }
    /* 定义一个倒计时的内部类 */
    internal inner class TimeCount(millisInFuture: Long, countDownInterval: Long)//参数依次为总时长,和计时的时间间隔
        : CountDownTimer(millisInFuture, countDownInterval) {
        override fun onFinish() {//计时完毕时触发

        }

        override fun onTick(millisUntilFinished: Long) {//计时过程显示
            web_live.loadUrl("https://blog.csdn.net/wz_1992/article/details/115934990")
        }
    }

}